package main

import (
	"fmt"
	"github.com/astaxie/beego/logs"
	"github.com/astaxie/beego/orm"
	_ "qycms/routers"
	"github.com/astaxie/beego"
	_"github.com/go-sql-driver/mysql"
	_"qycms/models/auth"
	_"qycms/models/adv"
	_"qycms/models/message"
	_"qycms/models/comment"
	_"qycms/models/member"
	_"qycms/models/article"
	_"qycms/models/set"
)

func init()  {
	//数据库配置
    username := beego.AppConfig.String("username");
    pwd := beego.AppConfig.String("pwd")
    host := beego.AppConfig.String("host")
    port := beego.AppConfig.String("port")
    db := beego.AppConfig.String("db")

    dataSource := username + ":" + pwd + "@tcp(" + host + ":" + port + ")/" + db + "?charset=utf8&loc=Local"
    orm.RegisterDriver("mysql",orm.DRMySQL)
    orm.RegisterDataBase("default","mysql",dataSource)

	ret := fmt.Sprintf("host:%s|port:%s|db:%s",host,port,db)
	logs.Info(ret)

}

func main() {

	//数据库迁移命令
	orm.RunCommand()

	//开启session
    beego.BConfig.WebConfig.Session.SessionOn = true

    //日志
    logs.SetLogger(logs.AdapterMultiFile,`{"filename":"logs/ions.log","separate":["error","info"]}`)
    logs.SetLogFuncCallDepth(3)

    beego.SetStaticPath("/upload","upload");
	orm.Debug = true
	beego.Run()
}

